package org.longgang.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.longgang.bean.User;
import org.springframework.stereotype.Repository;

/**
 * UserDAO继承基类
 */
@Repository
@Mapper
public interface UserDAO extends MyBatisBaseDao<User, Integer> {

	@Select({ "select * from user" })
	List<User> getUserAll();

	@Insert({ "insert into `user`(username,`password`,email) values (#{username}, #{password}, #{email})" })
	@Options(useGeneratedKeys = true, keyProperty = "userid", keyColumn = "userid")
	Integer insertUser(User info);

	@Select({ "select * from `user` where email= #{email}" })
	Integer selectUserByEmail(User info);

	@Select({ "select * from `user` where username= #{username}" })
	Integer selectUserByName(User info);

	@Select({ "select userid from `user` where email= #{email} and `password`= #{password}" })
	Integer selectUser(User info);
	
	@Select({ "select * from `user` where userid= #{userid}" })
	User selectUserById(User info);
}